//
//  MYGMyPageModels.swift
//  MYDoctor
//
//  Created by Denny on 2024/4/15.
//

import UIKit
import HandyJSON


struct MYGTopicModel:HandyJSON {
    var comment = ""
    var comment_count = ""
    var content = ""
    var created_at = ""
    var desc = ""
    var doctor_id = 0
    var enable = 0
    var heat = 0
    var id = 0
    var isLike = 0
    var is_hot = 0
    var like = 0
    var share = ""
    var share_count = ""
    var subdiscipline = ""
    var title = ""
    var updated_at = ""
    var doctor = MYGUserDoctor()
}

struct MYGFriendsModel:HandyJSON {
    var id = ""
    var user_id = ""
    var im_user_id = ""
    var origin_id = ""
    var from_user_id = ""
    var from_im_user_id = ""
    var from_origin_id = ""
    var status = ""
    var created_at = ""
    var updated_at = ""
    var from_doctor = MYGFriendsDoctorModel()
    var doctor = MYGFriendsDoctorModel()
    var doctor_id = -1
    var from_doctor_id = 0
    var patient_id = ""
    var from_patient_id = ""
    var is_mutual = 0
    var type = 0
    var selected = false
}

struct MYGFriendsDoctorModel:HandyJSON {
    var id = -1
    var name = ""
    var title = ""
    var avatar = ""
    var hospital = ""
    var department = ""
    var im_user_id = ""
    var phone = ""
}
struct MYGArticleListModel:HandyJSON {
    var list = [MYGArticleModel]()
    var total = 0
}

struct MYGArticleModel:HandyJSON {
    var browse_num = 0
    var collect_count = 0
    var is_collect = 0
    var created_at = ""
    var custom_browse_num = 0
    var custom_like_num = 0
    var doctor_id = 0
    var from = ""
    var id = 0
    var img = ""
    var like_num = 0
    var share_count = 0
    var title = ""
    var isEdit = false
    var isSelected = false
}

struct MYGArticleDetailModel:HandyJSON {
    var article_type = 0
    var author = ""
    var browse_num = 0
    var collect_count = 0
    var content = ""
    var created_at = ""
    var custom_browse_num = 0
    var custom_like_num = 0
    var desc = ""
    var doctor_id = 0
    var doi = ""
    var en_desc = ""
    var en_from = ""
    var en_title = ""
    var enable = 0
    var fm_img = ""
    var from = ""
    var from_url = ""
    var id = 0
    var img = ">"
    var index = ""
    var is_hot = 0
    var pmid = ""
    var share_count = 0
    var status =  0
    var sync_news = 0
    var title = ""
    var type = 0
    var updated_at = ""
    var video = ""
    var isLoad = false
}

struct MYGArticleFromModel:HandyJSON {
    var count = 0
    var from_count = [MYGFromModel]()
   
}
struct MYGFromModel:HandyJSON {
    var count = 0
    var from = ""
   
}


struct MYGTopicDetailModel:HandyJSON {
    var avatar = ""
    var comment = [String]()
    var content = ""
    var created_at = ""
    var department = ""
    var desc = ""
    var doctor = MYGUserDoctor()
    var doctor_id = ""
    var doctor_title = ""
    var enable = 0
    var hospital = ""
    var id = 0
    var isFlower = 0
    var isTomato = 0
    var is_collect = 0
    var is_hot = 0
    var is_like = 0
    var name = "";
    var subdiscipline = "";
    var title = "";
    var updated_at = 0.0;
    var isLoad = false
}

struct MYGTopicCollectionModel:HandyJSON {
    var comment = 0
    var content = ""
    var created_at:Double = 0.0
    var department = ""
    var desc = ""
    var doctor_id = 0
    var doctor_title = ""
    var enable = 0
    var hospital = ""
    var id = 72
    var is_hot = 0
    var is_like = 0
    var like = 1
    var name = ""
    var share = 0
    var subdiscipline = ""
    var title = ""
    var updated_at = ""
    var from_url = ""
    var img = ""
}

class MYGTopicCommentDoctorModel: HandyJSON {
    required init() {}
    var avatar = ""
    var id = ""
    var im_user_id = ""
    var name = ""
}
    
class MYGTopicCommentModel: HandyJSON {
    required init() {}
    var avatar = ""
    var children :[MYGTopicCommentModel]?
    var reply:[MYGTopicCommentModel]?
    var doctor = MYGTopicCommentDoctorModel()
    var patient: MYGTopicCommentDoctorModel?
    var comment = ""
    var created_at = ""
    var data_id = 0
    var doctor_id = 0
    var enable = 0
    var id = 0
    var is_like = 0
    var like_num = 0
    var likes = 0
    var name = ""
    var patient_id = 0
    var pid = 0
    var tatus = 0
    var type = 0
    var updated_at = 0.0
    var user_id = 0
    var user_type = 0
    
    func getCellHeight(isSub:Bool = false)->CGFloat{
        let lb = UILabel()
        lb.font =  isSub ? .regular(11) : .regular(14)
        lb.numberOfLines = 0
        lb.text = comment
        let commentHeight = lb.sizeThatFits(CGSize.init(width: screenWidth - (isSub ? 116 : 128), height: 100000)).height
        let otherHeight = isSub ? 50.0 : 70.0
        let result = commentHeight + otherHeight
        return result
    }
    
    func getAllReplyMoldes(replyArray:[MYGTopicCommentModel])->[MYGTopicCommentModel] {
        var result = [MYGTopicCommentModel]()
        for replyObject in replyArray {
            result.append(replyObject)
            if replyObject.reply?.count != 0 && replyObject.reply != nil{
                result.append(contentsOf: getAllReplyMoldes(replyArray:replyObject.reply!))
            }
        }
        return result
    }
}


struct MYGInformationModel:HandyJSON {
    var browse_num = 0
    var content = ""
    var created_at = ""
    var data_id = 0
    var data_type = ""
    var desc = ""
    var enable = 0
    var from = ""
    var from_img = ""
    var id = 0
    var img = ""
    var is_hot = 0
    var play_num = 0
    var title = ""
    var updated_at = ""
    var is_like = 0
    var is_collect = 0
    var is_share = 0
    var isLoad = false
}

struct MYGStatistics:HandyJSON {
    var followers = 0
    var following = 0
    var myFriends = 0
}

struct MYGShareMangerUserModel:HandyJSON {
    var name = ""
    var avatar = ""
}


struct MYGCollectlistModel:HandyJSON {
    var created_at = ""
    var data_id = ""
    var deleted_at = ""
    var doctor_id = ""
    var id = ""
    var patient_id = 0
    var type = 0
    var updated_at = ""
    var user_id = 0
    var news = MYGIndInfoModel()
    var topic = MYGTopicModel()
    var speech = MYGCollectSpeechModel()

}

struct MYGCollectSpeechModel: HandyJSON {
    var id = 0
    var room_id = 0
    var speechCn = ""
    var speechEn = ""
    var room = MYGCollectRoomModel()
    var expert = [MYGCollectExpertModel]()

}

struct MYGCollectRoomModel: HandyJSON {
    var id = 0
    var meeting_id = 0
    var roomCn = ""
    var sessionCn = ""
    var sessionTime = ""
    var sessionDate = ""
    var meeting = MYGCollectMeetModel()
    
}

struct MYGCollectMeetModel:HandyJSON {
    var id = 0
    var title = ""
}

struct MYGCollectExpertModel: HandyJSON {
    var id = 0
    var speech_id = 0
    var expertCn = ""
    var expertEn = ""
    var hospital = ""
}
struct MYGCloudShareCodeModel:HandyJSON {
    var code = ""
    var created_at = ""
    var f_id = 0
    var id = 0
    var time = 0
    var type = 0
    var updated_at = ""
}
